package song.NO_3;

import java.util.ArrayList;

public class lengthOfLongestSubstring {
    private String find_str;
    private String result;
    public lengthOfLongestSubstring(){}
    public lengthOfLongestSubstring(final String strs){
        this.find_str = strs;
        this.result = "";
    }
    public void excuting(){
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i != this.find_str.length(); ++i){
            var temp_find = Character.toString(this.find_str.charAt(i));
            var pos_xiangdui = builder.indexOf(temp_find); //重复字符对于当前处理的无重复子字符串中的相对位置
            if (pos_xiangdui == -1) builder.append(temp_find);
            else{
                if (this.result.length() < builder.toString().length()) this.result = builder.toString();
                builder.delete(0, pos_xiangdui+1); //清楚builder中出现该字符位置及之前的所有字符
                builder.append(this.find_str.charAt(i));
            }
        }
    }
    public void print(){
        System.out.println(this.result);
    }
}
